//
//  firstTableViewCell.m
//  半糖
//
//  Created by RenShuang on 15-9-2.
//  Copyright (c) 2015年 shuang. All rights reserved.
//

#import "firstTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "BaseHeader.h"

#define WIDTH [[UIScreen mainScreen] bounds].size.width
#define HEIGHT [[UIScreen mainScreen] bounds].size.height*7/24

@implementation firstTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.picImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 10, WIDTH-10, HEIGHT-10)];
        _picImageView.layer.masksToBounds = YES;
        _picImageView.layer.cornerRadius = HEIGHT/25;
      //  _picImageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_picImageView];
        [_picImageView release];
        
        _bgImageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, HEIGHT*4/5, WIDTH-10, HEIGHT*1/5)];
        [_bgImageView setImage:[UIImage imageNamed:@"底图.png"]];
        [_bgImageView setAlpha:0.7];
        [_bgImageView.layer setMasksToBounds:YES];
        [_bgImageView.layer setCornerRadius:HEIGHT/25];
        [self.contentView addSubview:_bgImageView];
        [_bgImageView release];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH-10, HEIGHT*1/5)];
        _titleLabel.font = [UIFont systemFontOfSize:18.];
        // _titleLabel.backgroundColor = [UIColor blackColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.textColor = [UIColor whiteColor];
        [_bgImageView addSubview:_titleLabel];
        [_titleLabel release];

        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(WIDTH*19/24, HEIGHT/15, WIDTH*11/72, WIDTH*11/72)];
        _bgView.backgroundColor = [UIColor blackColor];
        _bgView.alpha = 0.7;
        _bgView.layer.masksToBounds = YES;
        _bgView.layer.cornerRadius = WIDTH*11/800;
        [_picImageView addSubview:_bgView];
        [_bgView release];
        
        self.xinImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH/28, WIDTH/70, WIDTH/12, WIDTH/12)];
        _xinImageView.image = [UIImage imageNamed:@"xin.png"];
        [_bgView addSubview:_xinImageView];
        [_xinImageView release];
        
        
        self.likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, WIDTH/70+WIDTH/12, WIDTH*11/72, WIDTH*11/216)];
        self.likeLabel.textAlignment = NSTextAlignmentCenter;
       // self.likeLabel.backgroundColor = [UIColor redColor];
        _likeLabel.textColor = [UIColor whiteColor];
        [_bgView addSubview:_likeLabel];
        [_likeLabel release];
        
        
    }
    return self;
}


- (void)getcell:(firstTableModel *)model
{
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.pic]placeholderImage:[UIImage imageNamed:@"占位图.png"]];
    self.titleLabel.text = model.title;
    self.likeLabel.text = model.likes;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
